
<template>
  <div style="width: 1200px;margin: 100px auto;">
    <!--商品列表开始-->
    <el-row gutter="20">
      <el-col span="6" v-for="p in productArr">
        <el-card>
          <a :href="'/home/detail?id='+p.id">
            <img class="p_img" :src="p.url" width="100%"  height="233" alt="">
          </a>
          <div>
            <p style="font-size: 15px;height: 40px;margin-top: 0">
              <a :href="'/home/detail?id='+p.id">
                {{p.title}}
              </a>
            </p>
            <p style="font-size: 12px;color: #666">
              ￥{{p.price}} <s>{{p.oldPrice}}</s>
              <span style="float: right">销量:{{p.viewCount}}</span>
            </p>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>
<script>
export default {
  data() {
    return {
      productArr: []
    }
  },
  methods: {

  },
  created:function () {
    let url = "http://localhost:8090/product"
    console.log("url=" + url);
    this.axios.get(url).then((response) => {
      let responseBody = response.data;
      console.log(responseBody)
      this.productArr = responseBody.data;
      console.log(this.productArr)
    });
  }
}
</script>